package a66weding.com.jiehuntong.common;

import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.provider.Settings;

import a66weding.com.jiehuntong.R;


/***********************************************************************
 * @version : 1.0
 * @creator : alwaysbusyboy
 * @description : <描述>
 ***********************************************************************/
public class PromptManager {

    private static ProgressDialog dialog;

    public static void showProgressDialog(Context context) {
        dialog = new ProgressDialog(context);
        dialog.setIcon(R.mipmap.ic_launcher);
        dialog.setTitle(R.string.app_name);
        dialog.setMessage(context.getResources().getString(R.string.net_request));
        dialog.setCanceledOnTouchOutside(false);
        dialog.show();
    }

    public static void closeProgressDialog() {
        if (dialog != null && dialog.isShowing()) {
            dialog.dismiss();
        }
    }

    /**
     * 当判断当前手机没有网络时使用
     *
     * @param context
     */
    public static void showNoNetWork(final Context context) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setIcon(R.mipmap.ic_launcher)//
                .setTitle(R.string.app_name)//
                .setMessage("当前无网络").setPositiveButton("设置", new AlertDialog.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                // 跳转到系统的网络设置界面
                Intent intent = new Intent(
                        Settings.ACTION_WIFI_SETTINGS);
                context.startActivity(intent);

            }
        }).setNegativeButton("知道了", null).show();
    }

}
